-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract local Model scopes to Eloquent Builder traits #227
Extract local Model scopes to Eloquent Builder traits #227
Conversation
760db14
to
22c13ed
Compare
@vesper8 are you using custom Eloquent Builder classes? I'd prefer to go with this soltution. What do you think? |
Hrm... @antonkomarev yes actually I am using one because I also use https://github.com/MatanYadaev/laravel-eloquent-spatial Which requires this as part of its setup
And my models that are using this, are also Reacters or Reactants so.. if your package also starts requiring this.. I think it's going to cause a really bad conflict and I won't be able to use it.. or.. it will take some weird hacking so I can use both builders somehow? |
@vesper8 that's why I'm providing this methods as trait for the Eloquent Builder, but not actually builder. This way we will be able to compose them with other methods. I see here 2 ways:
|
@antonkomarev I like that link of thinking. Worse case if I need to fork or make my own builder and extend it, that won't be an issue.. I can manage that. |
In this solution I like that all these methods are placed as closer to Query Builder as possible and IDE auto-complete will work out of the box. |
50bb409
to
bcd0f58
Compare
@vesper8 Laravel Love v9 has been released with this feature and Laravel 10 support. |
This is breaking change!
Reactable trait methods
scopeWhereReactedBy
,scopeWhereNotReactedBy
,scopeJoinReactionCounterOfType
,scopeJoinReactionTotal
were moved toReactableEloquentBuilderTrait
.To start using them you have to create custom Eloquent Builder class, use trait in it and declare that it should be used in your model as default query builder in
newEloquentBuilder
method.